using System;
using System.Collections.Generic;
using System.Text;
using System.Configuration;

namespace PeoplesJukebox.Core.Configuration
{
    /// <summary>
    /// Collection of configured track settings
    /// </summary>
    [ConfigurationCollection(typeof(Track), 
        AddItemName="track", 
        CollectionType=ConfigurationElementCollectionType.BasicMap)]
    public class TrackCollection : ConfigurationElementCollection
    {
        /// <summary>
        /// Returns a new colleciton element
        /// </summary>
        /// <returns>New ReportEmail</returns>
        protected override ConfigurationElement CreateNewElement()
        {
            return new Track();
        }

        /// <summary>
        /// Returns the collection key value
        /// </summary>
        /// <param name="element">ReportEmail element</param>
        /// <returns>ReportName key value</returns>
        protected override object GetElementKey(ConfigurationElement element)
        {
            return ((Track)element).Position;
        }

        /// <summary>
        /// Returns the element name used for serializing the collection
        /// </summary>
        protected override string ElementName
        {
            get { return "track"; }
        }

        /// <summary>
        /// Returns the collection type used (BasicMap)
        /// </summary>
        public override ConfigurationElementCollectionType CollectionType
        {
            get { return ConfigurationElementCollectionType.BasicMap; }
        }

        /// <summary>
        /// Returns the track with the given idex
        /// </summary>
        /// <param name="index">Track index</param>
        /// <returns>Track</returns>
        public Track this[int index]
        {
            get { return (Track)base.BaseGet(index); }
        }

        /// <summary>
        /// Returns the track with the given position
        /// </summary>
        /// <param name="position">Track position</param>
        /// <returns>Track</returns>
        public Track GetConfiguredTrack(int position)
        {
            return (Track) this.BaseGet(position);
        }
    }
}